<template>
	<view class="app" style="padding: 10rpx;">
		<view style="background: #ffffff;padding: 20rpx;">
			<view style="font-size: 32rpx;text-align: center;">{{name}}</view>
			<view style="font-size: 32rpx;text-align: center;" v-if="description">{{description}}</view>
			<view v-if="type===0" style="font-size: 48rpx;text-align: center;">支付金额:{{money}}元</view>
		</view>
		<!-- #ifdef MP-WEIXIN || APP -->
		<button class="dflex-c dflex-flow-c no-border btn use-hover" style="color: #07c160" open-type="share">
			<view class="iconfont iconweixin padding-lr-sm border-radius-c fs-xxxl"></view>
			<view class="dflex-c fs-sm ft-dark">微信好友</view>
		</button>
		<view class="vertical-line"></view>
		<!-- #endif -->

	</view>
</template>

<script>
	import {
		mapState,
		mapGetters,
		mapMutations
	} from 'vuex'
	let _this;
	let _id
	export default {
		data() {
			return {
				type: "",
				name: "",
				description: "",
				money: "",
				href: "",
				imageUrl: ""
			}
		},
		onLoad(e) {
			_this = this
			if (e.collectionId) {
				_id = e.collectionId
			}
			this.getCollection()
		},
		methods: {
			getCollection() {
				_this.$func.wmzmall.call('collection/get', {
					_id: _id
				}).then(res => {
					if (res.code === 200) {
						var data = res.datas.data;
						console.log(data)
						this.money = data.money
						this.name = data.name
						this.description = data.description
						this.type = data.type
						this.imageUrl = data.imageUrl
						this.href = data.href
					} else {
						_this.$api.msg(res.msg);
					}
				}).catch(err => {
					console.log(err);
				});
			},
			onShareAppMessage: function(ops) {

				let image = this.imageUrl || '';
				let title = this.name || '待支付';
				let path = "/pages/collection/collection?collectionId="+_id;
				console.log(path)
				return {
					title: title,
					path: path,
					imageUrl: image,
					success: function(res) {
						// 转发成功
						console.log('转发成功', res);
					},
					fail: function(res) {
						// 转发失败
						console.log('转发失败', res);
					}
				};
			},
		},
	}
</script>

<style lang="scss">
	page {
		background: #f5f5f5;
	}

	.add-to-cart-btn {
		display: flex;
		justify-content: center;
		align-items: center;
		background-color: #DBA871;
		color: #ffffff;
		font-size: 26rpx;
		height: 80rpx;
		border-radius: 12rpx;
		margin-top: 100rpx;
	}
</style>